//
//  KZEveryDvdTableViewController.m
//  xiaorizi
//
//  Created by kun on 15/10/23.
//  Copyright © 2015年 origin. All rights reserved.
//

#import "KZEveryDvdTableViewController.h"
#import "dvdModel.h"
#import "KZGlobalApi.h"
#import "KZDvdCell.h"
#import "KZEveryDvdWebController.h"

@interface KZEveryDvdTableViewController ()

@end

@implementation KZEveryDvdTableViewController

- (void)viewDidLoad {
    
    self.url = [KZGlobalApi meijiUrl];
    self.cachePath = [KZGlobalApi meijiCachePath];
    self.refreshType = FLRefreshTypeHeader;

    [super viewDidLoad];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//重写父类方法

-(NSString *)JsonModelPath
{
    return [[NSBundle mainBundle]pathForResource:@"meiji" ofType:@"json"];
}


- (id)createDataWithNode:(id)node
{
    DvdModel *model = [DvdModel initWithDic:node];
    return model;
}

-(NSArray *)createDataArray:(NSDictionary *)dic
{
    NSArray *arrayData = dic[@"list"];
    
    return arrayData;
}




#pragma mark - Table view data source



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
   
    KZDvdCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    // Configure the cell...
    DvdModel *model = self.data[indexPath.row];
    
    [cell setImgButtonBlock:^(UITableViewCell * cell) {
        // [self setHidesBottomBarWhenPushed:YES];
        self.hidesBottomBarWhenPushed = YES;
        [self performSegueWithIdentifier:@"meiji" sender:model.themeurl];
       // [self setHidesBottomBarWhenPushed:NO];
    }];

    cell.model = model;
    
    return cell;
}


// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    NSString *themeUrl = sender;
    
    if([segue.identifier isEqualToString:@"meiji"])
    {
        KZEveryDvdWebController *webVc = [segue destinationViewController];
        webVc.themeurl = themeUrl;
        
    }
}



//控制tabbar
//-(void) viewWillDisappear:(BOOL)animated
//{
//    [super viewWillDisappear:animated];
//    self.tabBarController.tabBar.hidden = YES;
//}
//
//-(void)viewWillAppear:(BOOL)animated
//{
//    [super viewWillAppear:animated];
//    self.tabBarController.tabBar.hidden = NO;
//}
//




/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/



@end
